package hshs.process;

import hsh.setintructions.Instruction;
import hsh.util.Interruption;
import hsh.util.Priority;
import hsh.util.Status;

public class Process implements Comparable<Process>{

	public void setStatus(Status status) {
		this.status = status;
	}




	private Program program;
	private int pc;
	private double sumAmountSpendWater;
	private double sumAmountSpendEnergy;
	private Status status;
	private int priority;
	private int pid;
	
	
	
	
	public Status getStatus() {
		return status;
	}




	public Interruption executeNextInstruction(){
		Instruction instruction = this.program.getInstruction(pc);
		this.sumAmountSpendEnergy += instruction.geAmountSpendEnergy();
		this.sumAmountSpendWater += instruction.getAmountSpendWater();
		this.pc++;
		System.out.println("CHEGOU AKI");
		return instruction.execute();	
	}




	public Process(Program program,int pid) {
		super();
		this.program = program;
		this.status = Status.NEW;
		this.priority = 0;
		this.pc = 0;
		this.pid = pid;
		this.sumAmountSpendEnergy = 0.0;
		this.sumAmountSpendWater = 0.0;
	}




	public boolean isEmpty() {
		
		return this.pc >= this.program.length();
	}




	 
	public int compareTo(Process o) {
		
		return this.priority - o.priority;
	}




	public int getPid() {
		// TODO Auto-generated method stub
		return this.pid;
	}
	




}
